<!DOCTYPE html>
<html class="has-topbar has-bottombar">

	<head>
		<meta charset="utf-8">
		<script type="text/javascript" src="js/2h5_fb.js"></script>
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
		<link rel="shortcut icon" href="img/icon/bitbug_favicon.ico">
		<link rel="stylesheet" href="css/mui/mui.min.css" />
		<link rel="stylesheet" href="css/myAlert.css" />
		<link rel="stylesheet" href="css/bank/paycardmanager_grade.css" />
		<title>工资卡管理</title>
	</head>

	<body>
		<div class="a_ton" style="margin-top: 0.266666rem;">
			<div class="right" id="bindCard">
				<div class="mians">工资卡绑定</div>
				<img src="img/personal/personalha_08.png">
			</div>
			<div class="right" id="updateWithdrawPwd">
				<div class="mians">修改提现密码</div>
				<img src="img/personal/personalha_08.png">
			</div>
		</div>
		<div class="bgk_zzc"></div>
		<div class="gzk_mod">
			<div class="cf_bag"></div>
			<div class="mod_two">请先进行工资卡绑定</div>
			<div class="mod_btn">确定</div>
		</div>

		<div class="phonecover"></div>
		<div class="phonebox">
			<div class="cf_bag"></div>
			<div class="phone_title1">手机号绑定</div>
			<div class="phone_con">
				<div class="phone_title2">
					<span class="title1">手机号</span>
					<input type="text" maxlength="11" class="phone" id="phoneNum" />
				</div>

				<div class="phone_title3">
					<span class="title2">验证码</span>
					<input type="text" maxlength="6" class="code" id="code" />
					<button type="button" class="code_txt" id="code_btn">获取验证码</button>
				</div>

			</div>
			<div class="phone_btn" id="phone_btn">确定</div>
		</div>

		<div style="position: fixed;display:table;margin: 0 auto;width: 0px;height: 0px;;top: 45%;left: 50%;right: 50%;">
			<div id="myspin"></div>
		</div>
	</body>

	<script type="text/javascript" src="js/mui/mui.min.js"></script>
	<script type="text/javascript" src="js/jquery/jquery-2.1.4.min.js"></script>
	<script type="text/javascript" src="js/jquery/jquery.cookie.js"></script>
	<script type="text/javascript" src="js/spin/spin.min.js"></script>
	<script type="text/javascript" src="js/myAlert.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript" src="app/server.js"></script>
	<script type="text/javascript" src="js/util/util.js"></script>
	<script type="text/javascript">
		var token = "";
		var spinner = new Spinner(opts);
		var openid = getParam("openid"); //微信openid
		var countentPhone = getParam("countentPhone"); //手机框 0弹出1不弹出
		var userName = getParam("userName"); //用户昵称
		var userUrl = getParam("userUrl"); //用户头像
		var weixin_withdraw_sign = localStorage.getItem("weixin_withdraw_sign"); //判断不同的用户

		if(openid != "" && openid != "null" && openid != null) {
			sessionStorage.setItem("openid", openid);
		}
		if(userName != "" && userName != "null" && userName != null) {
			sessionStorage.setItem("weixin_userName", decodeURI(userName));
		}
		if(userUrl != "" && userUrl != "null" && userUrl != null) {
			sessionStorage.setItem("weixin_userUrl", userUrl);
		}

		if(countentPhone == "0") {
			$(".phonecover").show();
			$(".phonebox").show();
		}

		//获取验证码
		$("#code_btn").click(function() {
			var phoneNum = $("#phoneNum").val(); //手机号
			var flag = checkPhone(phoneNum);
			if(flag) {
				var param = {};
				param.phone = phoneNum;
				param.type = 6;
				//获取验证码接口上送
				gainCode(param, function(data) {
					token = data;
					//开启验证码定时器
					for(i = 1; i <= 60; i++) {
						if(i == 1) {
							window.setTimeout("countDown(" + i + ")");
						} else {
							window.setTimeout("countDown(" + i + ")", (i - 1) * 1000);
						}
					}
				});
			}
		})

		//手机号绑定确定
		$("#phone_btn").click(function() {
			var phone = $("#phoneNum").val(); //手机号
			var code = $("#code").val();
			//校验验证码接口上送
			var param = {};
			param.phone = phone;
			param.type = 6;
			param.code = code;
			param.token = token;
			mateCode(param, function() {
				var param = {};
				param.userid_sign = sessionStorage.getItem("openid");
				param.phone = phone;
				param.userName = sessionStorage.getItem("weixin_userName");
				param.userUrl = sessionStorage.getItem("weixin_userUrl");
				//微信绑定客户手机号
				bindCustomerPhone(param, function(resultObj) {
					closeSpin()
					$(".phonecover").hide();
					$(".phonebox").hide();
				});
			})
		})

		//工资卡绑定
		$("#bindCard").click(function() {
			if(sessionStorage.getItem("openid")) {
				sessionStorage.setItem("paycard_sign", 001177);
				localStorage.setItem("weixin_withdraw_sign", sessionStorage.getItem("openid")); //验证不同用户登录后提现密码次数的问题
				if(sessionStorage.getItem("openid") != weixin_withdraw_sign) { //不是当前用户清除十分钟次数和cookie的时间
					localStorage.removeItem("sess_time_local");
					$.cookie("sess_time_local", "", {
						expires: -1,
						path: '/bluehired'
					})
				}

				var param = {};
				param.userid_sign = sessionStorage.getItem("openid");
				//查询工资卡信息
				queryIsBindCard(param, function(resultObj) {
					if(resultObj.data != null) {
						var bankObj = resultObj.data;
						if(bankObj.bankNumber != "" && bankObj.bankNumber != null) {
							var regPhone = bankObj.phone; //系统手机号-账号
							sessionStorage.setItem("reg_phone", regPhone);
							sessionStorage.setItem("bank_user_name", bankObj.userName);
							sessionStorage.setItem("identity_no", bankObj.identityNo);
							sessionStorage.setItem("card_no", bankObj.bankNumber);
							sessionStorage.setItem("reserved_phone", bankObj.bankUserTel);
							//换绑
							window.location.href = "app/bank/paycardbinding_asce.html";
						} else {
							sessionStorage.setItem("bank_user_name", bankObj.userName);
							sessionStorage.setItem("identity_no", bankObj.identityNo);
							window.location.href = "app/bank/paycardbinding.html";
						}
					} else { //绑定工资卡
						window.location.href = "app/bank/paycardbinding.html";
					}
				})
			}
		})

		//修改提现密码
		$("#updateWithdrawPwd").click(function() {
			if(sessionStorage.getItem("openid")) {
				sessionStorage.setItem("paycard_sign", 001177);
				localStorage.setItem("weixin_withdraw_sign", sessionStorage.getItem("openid")); //验证不同用户登录后提现密码次数的问题
				if(sessionStorage.getItem("openid") != weixin_withdraw_sign) { //不是当前用户清除十分钟次数和cookie的时间
					localStorage.removeItem("sess_time_local");
					$.cookie("sess_time_local", "", {
						expires: -1,
						path: '/bluehired'
					})
				}
				
				var param = {};
				param.userid_sign = sessionStorage.getItem("openid");
				//查询工资卡信息
				queryIsBindCard(param, function(resultObj) {
					if(resultObj.data != null) {
						var bankObj = resultObj.data;
						if(bankObj.bankNumber != "" && bankObj.bankNumber != null) {
							var regPhone = bankObj.phone; //系统手机号-账号
							sessionStorage.setItem("reg_phone", regPhone);
							window.location.href = "app/bank/withdrawpwd_update.html";
						} else {
							$(".bgk_zzc").show();
							$(".gzk_mod").show();
						}
					} else { //提示先绑定工资卡
						$(".bgk_zzc").show();
						$(".gzk_mod").show();
					}
				})
			}
		})

		//提示框
		$(".mod_btn").click(function() {
			$(".bgk_zzc").hide();
			$(".gzk_mod").hide();
		})
	</script>

</html>